home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1997 February / PC Plus Super CD (Issue 124) (PCP124-2-97) (February 1997).iso / javadem1 / lessons / glossary.bak < prev    next >
Encoding:
Text File  |  1980-01-06  |  35.2 KB  |  1,005 lines

  1. >>
  2. <<
  3. >>>
  4. &
  5. &&
  6. |
  7. ||
  8. %
  9. Access control
  10. API
  11. Applet
  12. Application
  13. Array
  14. Boolean
  15. Break
  16. Byte
  17. Bytecode
  18. Cast
  19. Char
  20. Class
  21. Compiler
  22. Constructor
  23. Continue
  24. Detour
  25. Do
  26. Event
  27. Exception handling
  28. Expression
  29. FAQ
  30. Field
  31. Field Method
  32. Field Variable
  33. Final
  34. For
  35. Frame
  36. Hash table
  37. HTML
  38. If
  39. Inheritance
  40. Integer
  41. Interpreter
  42. Java
  43. Javac
  44. Java API
  45. Layout manager
  46. Long
  47. Method
  48. Multi-threading
  49. Object-oriented programming
  50. Override
  51. Package
  52. Parameter
  53. Pass by reference
  54. Pass by value
  55. Private
  56. Protected
  57. Public
  58. Reference
  59. Return
  60. Short
  61. Stack
  62. Static
  63. Stream
  64. String
  65. Synchronized
  66. Switch
  67. Talk Java to Me
  68. Telecommunications
  69. Thread
  70. Variable
  71. Vector
  72. While
  73. *>>
  74. This is a Java operator which shifts the bits of a numeric value to the right.  It duplicates
  75. the left-most bit, which is the sign bit, as it shifts.  So, an integer of 256, which is 0x00000100 in
  76. hex, can be right-shifted one position with "256 >> 1", which gives the value 128 or 0x00000080.  An
  77. integer of -256, which is 0xffffff00 in hex, can be right-shifted with "256 >> 1" which gives the value
  78. -128 or 0xffffff80.
  79.  
  80. The ">>>" operator performs a similar function, but always adds zero bits on the left-hand
  81. end, rather than duplicating the left-most bit.
  82. *<<
  83. This is a Java operator which shifts the bits of a numeric value to the left.  It adds zero bits
  84. on the right-hand end as it shifts.  So, an integer of 256, which is 0x00000100 in
  85. hex, can be left-shifted one position with "256 << 1", which gives the value 512 or 0x00000200.  An
  86. integer of -256, which is 0xffffff00 in hex, can be left-shifted with "256 << 1" which gives the value
  87. -512 or 0xfffffe0.
  88. *>>>
  89. This is a Java operator which shifts the bits of a numeric value to the right.  It adds zero bits
  90. on the left-hand end as it shifts.  So, an integer of 256, which is 0x00000100 in
  91. hex, can be right-shifted one position with "256 >>> 1", which gives the value 128 or 0x00000080.
  92.  
  93. This operator is also known as the "unsigned right-shift operator" because it is usually applied
  94. only to unsigned values.  That is because the sign bit will always become zero as a result of using
  95. this operator, which means the resulting value will always be positive.
  96.  
  97. The ">>" operator performs a similar function, but always duplicates the left-most bit (the sign
  98. bit) as it shifts.  That makes it more appropriate for use with signed values.
  99. *&
  100. This is the "bitwise and" operator.  It "ands" two operands together, one bit at a time.  For
  101. example, if you had the values 0x0000ffff and 0x10101010, you could "and" them together with
  102. "0x0000ffff & 0x10101010", which would result in the value "0x00001010".
  103.  
  104. This operator is easily confused with the "&&" operator, which performs a "logical and".  That
  105. means it "ands" two boolean values (values of "true" or "false"), rather than two numeric values.
  106. The two operators seem similar, but are quite different, and are not interchangable.
  107. *&&
  108. This is the "logical and" operator.  It "ands" two boolean values together.  For example, you
  109. might have the expression "a == 5", which results in a boolean ("true" or "false") value; you might
  110. also have the expression "b > 0", which also results in a boolean value.  You can determine if
  111. both values are true by "and'ing" them together with the expression "(a == 5) && (b > 0)".  The
  112. result will be "true" if both of the sub-expressions is true; otherwise, it will be false.
  113.  
  114. This operator is easily confused with the "&" operator, which performs a "bitwise and".  That means
  115. it "ands" two numeric values together, one bit at a time.  These two operators seem similar,
  116. but are quite different, and are not interchangeable.
  117. *|
  118. This is the "bitwise or" operator.  It "ors" two operands together, one bit at a time.  For
  119. example, if you had the values 0x0000ffff and 0x10101010, you could "or" them together with
  120. "0x0000ffff | 0x10101010", which would result in the value "0x1010ffff".
  121.  
  122. This operator is easily confused with the "|" operator, which performs a "logical or".  That
  123. means it "ors" two boolean values (values of "true" or "false"), rather than two numeric values.
  124. The two operators seem similar, but are quite different, and are not interchangable.
  125. *||
  126. This is the "logical or" operator.  It "ors" two boolean values together.  For example, you
  127. might have the expression "a == 5", which results in a boolean ("true" or "false") value; you might
  128. also have the expression "b > 0", which also results in a boolean value.  You can determine if
  129. either (or both) values are true by "or'ing" them together with the expression "(a == 5) || (b > 0)".  The
  130. result will be "true" if either (or both) of the sub-expressions are true; otherwise, it will be false.
  131.  
  132. This operator is easily confused with the "|" operator, which performs a "bitwise or".  That means
  133. it "ors" two numeric values together, one bit at a time.  These two operators seem similar,
  134. but are quite different, and are not interchangeable.
  135. *%
  136. This is Java's "remainder" operator.  It returns the remainder left after an integer division.  For
  137. example, "7 % 3" has a value of 1, because "7 / 3" is 2 with a remainder of 1.
  138. *Access control
  139. This refers to controlling which parts of a program have access to certain field variables or
  140. methods of a class.  For example, a field variable might be declared as "private", which means
  141. it can be used only by members of the class in which it is declared.
  142.  
  143. There are several different access levels provided by Java, which are summarized in Figure XXX
  144. in the "Talk Java to Me" book.
  145. *API
  146. This stands for "application program interface", and is a general term refering to the way in
  147. which a program uses a set of functions.
  148.  
  149. The "Java API" refers to the set of standard classes which are part of Java.
  150. *Applet
  151. This is a small Java program which normally is part of a World Wide Web page.  The Java code is
  152. automatically executed when the Web page is displayed by a Java-capable Web browser, which can
  153. add animation or interactivity to a Web page.
  154.  
  155. A more precise definition would be a piece of Java code which consists of a sub-class of the
  156. Applet class.  The "Applet" class is one of the standard Java classes.
  157.  
  158. Another kind of Java program is an "application".  An
  159. "applet" is different from an "application" in that an "applet" is generally part of some larger
  160. whole, most commonly a Web page, and is executed as a "side effect" of opening that page.  An
  161. "application", on the other hand, is a piece of Java code
  162. which can be complete by itself, and which is executed directly by the user.
  163. *Application
  164. This is a Java program which is run directly by the user.  It often is a complete program
  165. by itself, needing no other code to execute.
  166.  
  167. Another kind of Java program is an "applet".  An
  168. "applet" is different from an "application" in that an "applet" is generally part of some larger
  169. whole, most commonly a Web page, and is executed as a "side effect" of opening that page.  An
  170. "application", on the other hand, is a piece of Java code
  171. which can be complete by itself, and which is executed directly by the user.
  172. *Array
  173. An "array" is simply a series of
  174. values, that are treated as a group.  For example, you might have a
  175. vector that is 10 integers, each of which represents the age of an employee.  You could
  176. declare the vector like this:
  177.  
  178.     int ages[10] = {18,18,35,53,39,39,27,44,42,60};
  179.  
  180. You could calculate the average age like this:
  181.  
  182.     float average;
  183.     int sum = 0;
  184.     int i;
  185.  
  186.     for (i=0; i<10; ++i) {
  187.         sum += ages[i];
  188.     }
  189.  
  190.     average = sum / 10;
  191.  
  192. In addition to being a synonym for "array", "vector" can also refer to
  193. an object of the "Vector" class.  The "vector" class is one of the standard
  194. Java classes, and provides a way to create arrays that can have varying sizes.
  195. *Boolean
  196. One of the basic Java data types, a "boolean" always has a value of either "true" or "false".
  197.  
  198. The following example declares the variable "a" to be a boolean, and assigns a value of "true" to it:
  199.  
  200.     boolean a;
  201.     a = true;
  202. *Break
  203. This is a Java statement which causes the loop it is contained within to be exited.  The "loop"
  204. can be a "for", "while", or "do" loop.  For example, the following use of the statement causes
  205. the loop to end if the "sum" exceeds 100:
  206.  
  207.     int sum = 0;
  208.     int i;
  209.  
  210.     for (i=0; i<100; ++i) {
  211.         sum += i*i;
  212.         if (sum > 100) {
  213.             break;
  214.         }
  215.     }
  216.  
  217. It can also be used in a "switch" statement to exit from one of the cases:
  218.  
  219.     switch (a) {
  220.  
  221.     case 10:
  222.         b = 5;
  223.         break;
  224.  
  225.     case 20:
  226.         b = 6;
  227.         c = false;
  228.         break;
  229.  
  230.     }
  231. *Byte
  232. In general, this is a set of 8 bits of computer memory.  In a Java program, it is also
  233. one of the basic Java data types, which is 8 bits in length.  It can be treated like a
  234. small integer:
  235.  
  236.     byte a;
  237.  
  238.     a = (byte)5*c;
  239.  
  240. Note that a "byte" is not the same thing as a character.  In Java, characters are stored
  241. in Unicode format, which means each character takes 16 bits of storage.  Characters are
  242. normally stored using the "char" and "String" types.
  243. *Bytecode
  244. This is the form in which a compiled Java program is stored.
  245.  
  246. When you write a Java program, you write it in source form.  You then run a Java compiler
  247. (such as "javac") against it, creating a "bytecode file".  This is the same program,
  248. but in a form that is easier for the Java interpreter to use.  The Java interpreter can
  249. then be used to execute the bytecode file.
  250.  
  251. By Java convention, bytecode files always end with the extension ".class".
  252. *Cast
  253. This is the process of converting one data type to another.  For example, the Java
  254. expression "5 * c" will yield an integer value if "c" is an integer.  To assign that
  255. value to a "short" variable, you must "cast" the value into a short, like this:
  256.  
  257.     int c = 12;
  258.     short a;
  259.  
  260.     a = (short)(5 * c);
  261.  
  262. It is generally legal to cast any of the native Java data types to another, although
  263. there are a few exceptions (such as casting a numeric value into a boolean).
  264.  
  265. It is also possible to cast an object into a different class, but this requires that
  266. the resulting class be a sub-class or super-class of the original class.
  267. *Char
  268. This is one of the native Java data types.  It is normally used to hold a single
  269. character.  Because characters are stored using Unicode in Java, each character
  270. requires 16 bits of storage.
  271.  
  272. For example, the following code creates a "char" variable, and stores the letter "a"
  273. in it:
  274.  
  275.     char c;
  276.  
  277.     c = 'a';
  278. *Class
  279. A "class" defines certain data ("field variables"), and processes ("field methods")
  280. which can be performed on that data.
  281.  
  282. For example, the following class defines the data required to store a date, and
  283. a method that will assign a value to that date:
  284.  
  285.     public class date {
  286.  
  287.         int year;
  288.         int month;
  289.         int day;
  290.  
  291.         void Set(int y,int m,int d) {
  292.             day = d;
  293.             month = m;
  294.             if (y > 99) {
  295.                 year = y;
  296.             } else if (y >= 90) {
  297.                 year = 1900 + y;
  298.             } else {
  299.                 year = 2000 + y;
  300.             }
  301.         }
  302.  
  303.     }
  304.  
  305. Once a class like this is defined, it can be used to create "objects" of the
  306. class (e.g., to create "dates") like this:
  307.  
  308.     date a;
  309.  
  310. The "methods" in the class can be used to perform operations on these objects:
  311.  
  312.     a.set(2010,10,10);
  313. *Compiler
  314. In the case of Java, this is a utility which converts a Java program from the form
  315. in which it was written by a human ("source" form) into the form used when it is
  316. run by a Java interpreter ("bytecode" form).
  317.  
  318. One common Java compiler is provided as part of the Java Developer's Kit, and is
  319. named "javac".  That compiler, along with the rest of the Java Developer's Kit, is
  320. included on this CD-ROM.
  321. *Constructor
  322. When a Java class is declared, it will generally include several "methods", which
  323. can be used to process the data ("field variables") in the class.
  324.  
  325. A "constructor" is a special kind of "method".
  326.  
  327. It is special because it is not used to process an object that already exists (like the
  328. other methods are), but rather is used to initialize a new object when that
  329. object is created.
  330.  
  331. For example, you might have the class:
  332.  
  333.     public class Date {
  334.  
  335.         int year;
  336.         int month;
  337.         int day;
  338.  
  339.         Date(int y) {
  340.             day = 1;
  341.             month = 1;
  342.             year = y;
  343.         }
  344.  
  345.         void Set(int y,int m,int d) {
  346.             day = d;
  347.             month = m;
  348.             year = y;
  349.         }
  350.  
  351.     }
  352.  
  353. This class has two methods:  "Set" and "Date"; only "Date" is a constructor.  It would
  354. be called when you create a new Date object, like this:
  355.  
  356.     Date a;
  357.  
  358.     a = new Date(2010);
  359. *Continue
  360. This is a Java statement which can be used to continue the execution of a loop, but to
  361. end the current iterration of that loop.
  362.  
  363. For example:
  364.  
  365.     for (i=0; i<20; ++i) {
  366.         sum += i;
  367.         if (product > 50) {
  368.             continue;
  369.         }
  370.         product *= i;
  371.     }
  372.  
  373. The "continue" statement here would prevent the repetition of the statement "product *= i" once
  374. the product reached a value of 50 or more.  But, since the "continue" statement won't effect
  375. the "sum += i" statement, it will be performed as long as the "for" loop runs.
  376. *Detour
  377. This is one of the buttons on the control panel in this CD-ROM.  It is used
  378. to allow you to skip certain topics which may not be of interest to everyone.
  379.  
  380. The button is disabled during much of the CD, because the topics being covered are
  381. considered to be important to anyone planning to program in Java.  When an optional
  382. topic begins, the narrator will tell you it's optional, and the detour button
  383. will become enabled.
  384. *Do
  385. This is one of the looping statements in Java.  For example:
  386.  
  387.     do {
  388.         sum *= 1.01;
  389.         ++i;
  390.     } while (i < 10);
  391.  
  392. This will cause the statements "sum *= 1.01;" and "++i;" to be executed over and
  393. over, as long as "i" remains less than "10".
  394.  
  395. A similar loop is:
  396.  
  397.     while (i < 10) {
  398.         sum *= 1.01;
  399.         ++i;
  400.     }
  401.  
  402. The second loop is almost idential to the first.  The only difference is that the
  403. first loop will always execute the statements "sum *= 1.01;" and "++i" at least once,
  404. regardless of the initial value of "i".  The second loop, on the other hand, would
  405. never execute the statements if "i" is at least 10 when the loop begins.
  406. *Event
  407. An event in Java means the same thing it does in the real world:  "something
  408. happened".  In the case of a Java program, the sorts of things that can happen
  409. are things like "the mouse was pressed down", "the mouse moved", "a key was
  410. pressed", etc.
  411.  
  412. A Java program can have methods that are automatically called when an event
  413. occurs.  For example, if you sub-class the "Applet" class, and override the method
  414. "mouseDown", your method will be called when the user presses down the mouse
  415. inside the Applet:
  416.  
  417.     public class myApplet extends Applet {
  418.  
  419.         mouseDown(Event e,int x,int y) {
  420.             /* handle the event here */
  421.         }
  422.  
  423.     }
  424. *Exception handling
  425. In most cases, you can think of this as "error handling".  It refers to the
  426. way Java programs identify and route information to deal with an error.
  427.  
  428. A simple example would be:
  429.  
  430.     try {
  431.         myMethod(a);
  432.     } catch (IllegalArgumentException e) {
  433.         System.out.println("I've located too many widgets");
  434.         System.exit(0);
  435.     }
  436.  
  437. This will try to execute the method "myMethod".  If it fails due to
  438. an illegal argument, the calls to "System.out.println" and "System.exit" will
  439. be made.
  440.  
  441. Within "myMethod", you might indicate an error as follows:
  442.  
  443.     void myMethod(int a) {
  444.         if (a > 5) {
  445.             throw new IllegalArgumentException();
  446.         }
  447.         sum += a;
  448.     }
  449.  
  450. For more details, see lesson 9 which discusses exception handling.
  451. *Expression
  452. This is a basic building block of most languages, including Java.  It consists
  453. of a series of literal values like "5" or "1.23", combined with a series
  454. of variables like "sum" and "a", held together with operators like "+" and "*".
  455.  
  456. For example, these are expressions:
  457.  
  458.     a
  459.     5
  460.     a * 5
  461.     ++a
  462.     (a > 5 ? ((4 & b) | (8 & c)) : (d >> (e-3)))
  463.  
  464. The parts of an expression are literals (like "5" or "1.23"), variables (like "a"
  465. or "b") and operators (like "*" or "&").
  466. *FAQ
  467. This stands for "frequently asked question".  It is a general term used with
  468. computers.  In the case of this CD, it is also a folder you can open to
  469. view frequently-asked questions (and their answers).
  470. *Field
  471. This is a part of a class.
  472.  
  473. Fields come in two types:  "field variables" and "field methods".
  474.  
  475. For example:
  476.  
  477.     public class Date {
  478.  
  479.         int year;
  480.         int day;
  481.         int month;
  482.  
  483.         Date(int y) {
  484.             day = 1;
  485.             month = 1;
  486.             year = y;
  487.         }
  488.  
  489.         void Set(int y,int m,int d) {
  490.             day = d;
  491.             month = m;
  492.             year = y;
  493.         }
  494.  
  495.     }
  496.  
  497. This class includes 5 fields:  "year", "day", and "month" are "field variables",
  498. and "Date" and "Set" are "field methods".
  499.  
  500. "Field variables" are the data which make up an object, and "field methods" are
  501. the processes you can perform on those objects.
  502. *Field Method
  503. This is part of a class which defines a process to be performed on an
  504. object of the class.
  505.  
  506. For example:
  507.  
  508.     public class Date {
  509.  
  510.         int year;
  511.         int day;
  512.         int month;
  513.  
  514.         void Set(int y,int m,int d) {
  515.             day = d;
  516.             month = m;
  517.             year = y;
  518.         }
  519.  
  520.     }
  521.  
  522. This class includes "Set", which is a "field method".  It allows you to set the
  523. date for a date object.
  524.  
  525. "Field methods" are normally called just "methods".
  526. *Field Variable
  527. This is a variable which is part of a class.  For example:
  528.  
  529.     public class Date {
  530.  
  531.         int year;
  532.         int day;
  533.         int month;
  534.  
  535.         void Set(int y,int m,int d) {
  536.             day = d;
  537.             month = m;
  538.             year = y;
  539.         }
  540.  
  541.     }
  542.  
  543. This class includes "year", "day", and "month", all of which are "field variables".
  544. *Final
  545. This is a keyword which indicates that a variable may not have its value changed.  For
  546. example:
  547.  
  548.     public class Date {
  549.  
  550.         final int maxMonth 12
  551.  
  552.         int year;
  553.         int day;
  554.         int month;
  555.  
  556.     }
  557.  
  558. The variables "year", "month", and "day" can all be modified; the variable
  559. "maxMonth" cannot.
  560.  
  561. The keyword can also be used on methods.  In that case, it indicates that the
  562. method cannot be overrided in sub-classes.
  563. *For
  564. This is a statement in Java which performs a loop.  For example:
  565.  
  566.     for (i=0; i<5; ++i) {
  567.         System.out.println(i);
  568.     }
  569.  
  570.  
  571. This will cause the following output:
  572.  
  573.     0
  574.     1
  575.     2
  576.     3
  577.     4
  578. *Frame
  579. What Java calls a "frame" would, in many environments, be called a "window".  One
  580. of the standard Java classes is the "Frame" class, which allows a Java program
  581. to create a "frame" or "window".
  582.  
  583. For information on how to use Java's Frame class, see Lesson 6.
  584. *Hash table
  585. This a common data structure which acts as an index for a series of objects.  Each
  586. 0bject entered in the hash table is identified with a unique "key".  The index can
  587. later be searched for a given key, and if the key is in the table the corresponding object
  588. will be returned.
  589.  
  590. In Java, there is a "HashTable" class in the standard Java library.  For information
  591. on how to use it, see Lesson 11.
  592. *HTML
  593. Pages on the World Wide Web are constructed using a special language called "HTML" which
  594. stands for "Hyper Text Markup Language".  This is a very simple language which allows
  595. you to indicate what text and graphics should appear on the page, and what special characteristics
  596. (such as "bold" or "indented") it should have.
  597.  
  598. HTML can also be used to identify a Java applet which should be included on the
  599. page.  For information on how to do this, see Lesson 4.
  600. *If
  601. This is a Java statement which allows you to perform a test.  Depending upon the
  602. results of that test, some additional Java code will either be executed or skipped.
  603.  
  604. For example:
  605.  
  606.     if (a > 5) {
  607.         b = 6;
  608.     }
  609.  
  610. Here the test is "a > 5".  If the test is true, the statement "b = 6;" will be
  611. executed.
  612. *Inheritance
  613. When a Java class is declared, it can be identified as being a "sub-class" of
  614. another class.  Being a "sub-class" means the new class can use all the field
  615. variables and methods of the "super class", but it can also add its own
  616. field variables and methods.  This, in effect, allows you to create a
  617. special variation of the "super class".
  618.  
  619. The act of using a field variable or method from the "super class" is called
  620. "inheriting" the variable or method.
  621. *Integer
  622. This is one of the basic data types in Java.  It is an integer (i.e., "whole number")
  623. which can range from -2,147,483,648 to 2,147,483,647, and takes 32 bits of storage.
  624.  
  625. For example, the following code declares an integer variable and assigns it a value:
  626.  
  627.     int a;
  628.  
  629.     a = 1047;
  630. *Interpreter
  631. After you write a Java program, you run it through a program called a "compiler".  In
  632. the case of Java, one of the common compilers is named "javac".  A Java compiler will
  633. translate the program into a special format called "bytecode".
  634.  
  635. To execute the program, the "bytecode" file is processed by a program called an "interpreter".  It
  636. carries out the instructions contained in the "bytecode" file similarly to the way
  637. a processor carries out instructions in an ".exe" file.
  638. *Java
  639. A computer programming language developed by Sun Microsystems.
  640.  
  641. The name "Java" doesn't stand for anything, and it's not someone's name.  Rather, it
  642. projects the kind of "hip" and "energetic" image that the developers wanted to have.
  643. *Java API
  644. The "Java API" refers to the set of standard classes which are part of Java.
  645.  
  646. "API" is a general programming term which stands for "application programming interface".  It can
  647. refer to the set of rules used to use any set of functions from a program.
  648. *Javac
  649. The "javac" compiler is the most common Java compiler, and is part of the Java Development Kit
  650. written by Sun Microsystems.  This compiler, along with the rest of the Java Development Kit,
  651. are included on this CD-ROM.
  652. *Layout manager
  653. A "layout manager" is a class which determines the position and size of a control (or other object)
  654. within an area of the display (such as a frame or panel).
  655.  
  656. There are several layout managers included in the standard Java classes, including the "GridLayoutManager"
  657. and the "FlowLayoutManager".  It is also possible to write your own layout manager by creating a
  658. subclass of the "LayoutManager" class.
  659. *Long
  660. This is one of the basic Java data types.  It holds integers (i.e., "whole numbers") which
  661. can range from about -9,000,000,000,000,000,000 to 9,000,000,000,000,000,000.  Each
  662. long variable takes 64 bits of storage.
  663. *Method
  664. This is part of a class which defines a process to be performed on an
  665. object of the class.
  666.  
  667. For example:
  668.  
  669.     public class Date {
  670.  
  671.         int year;
  672.         int day;
  673.         int month;
  674.  
  675.         void Set(int y,int m,int d) {
  676.             day = d;
  677.             month = m;
  678.             year = y;
  679.         }
  680.  
  681.     }
  682.  
  683. This class includes "Set", which is a "method".  It allows you to set the
  684. date for a date object.
  685.  
  686. "Methods" are sometimes called "field methods".
  687. *Multi-threading
  688. This refers to having more than one "thread" in a program.  Each "thread" runs independently
  689. of the other threads in the program, and runs at the same time.  This can allow
  690. different parts of the program to be running simultaneously, or can allow the same part
  691. of the program to be running more than once simultaneously.
  692.  
  693. For more information on "threads", see Lessons 5 and 11.
  694. *Object-oriented programming
  695. This is a way of programming in which the program is broken into parts called "classes".  Each "class"
  696. describes a certain kind of object.  The description of that kind of object consists of defining
  697. what data must be stored for it, and what processes can be performed on it.
  698.  
  699. The power of object-oriented programming comes from many characteristics, but perhaps chief among
  700. them is that it allows pieces of code from one program to be easily and seamlessly re-used in
  701. another program.
  702.  
  703. For a complete introduction to object-oriented programming, see Lesson 3.
  704. *Override
  705. When you define a class, you can declare it to be a "sub-class" of another class.  That other
  706. class is known as the "super-class".
  707.  
  708. The advantage of doing this is that you can use the field variables and methods of the super-class, but
  709. add your own field variables and methods to it.  This allows you to use the parts of the super-class
  710. that apply, but to customize it where appropriate.
  711.  
  712. While methods from the super-class are often used in the sub-class without change (i.e., they are
  713. "inherited"), they are sometimes replaced with different methods.  This replacement is
  714. known as "overriding" the method.  (The same thing can be done with field variables, although
  715. that is less common.)
  716. *Package
  717. This is a collection of classes that work in concert.  They are generally placed in a separate
  718. directory, and are identified as belonging to the same package with the "package" statement.
  719.  
  720. Putting classes together into a package is largely a matter of convenience, since it gives a clear
  721. structure to users and makes it easy for them to import the package into their programs.  It also
  722. increases the access that members of the package have to other members and field variables in the package.
  723. *Parameter
  724. This is an item sent to a method.  The item can be either a variable of one of the standard
  725. Java data types (e.g., "int"), or it can be an object (e.g., "String").
  726. *Pass by reference
  727. There are two ways data can be sent to a method.
  728.  
  729. The first, "pass by reference", means that you
  730. are sending the location of the piece of data.  This means there is only one copy of the data, and
  731. that if the method modifies it, the modification will be visible to the code that called the method.
  732.  
  733. The other method is "pass by value".  In this approach, a copy is made of the data, and that copy
  734. is sent to the method.  This means that if the method changes the data, the original copy will remain
  735. intact, so the modification will be invisible to the code that called the method.
  736.  
  737. Java uses "pass by reference" for any objects or arrays sent to methods.  It uses "pass by value"
  738. for native data types (e.g., "int" or "float") sent to methods.
  739.  
  740. The difference between these is important to understand so you will know what to expect when
  741. a method you are writing modifies one of the parameters sent to it.
  742. *Pass by value
  743. There are two ways data can be sent to a method.
  744.  
  745. The first, "pass by reference", means that you
  746. are sending the location of the piece of data.  This means there is only one copy of the data, and
  747. that if the method modifies it, the modification will be visible to the code that called the method.
  748.  
  749. The other method is "pass by value".  In this approach, a copy is made of the data, and that copy
  750. is sent to the method.  This means that if the method changes the data, the original copy will remain
  751. intact, so the modification will be invisible to the code that called the method.
  752.  
  753. Java uses "pass by reference" for any objects or arrays sent to methods.  It uses "pass by value"
  754. for native data types (e.g., "int" or "float") sent to methods.
  755.  
  756. The difference between these is important to understand so you will know what to expect when
  757. a method you are writing modifies one of the parameters sent to it.
  758. *Private
  759. Java provides the ability to control what access certain types of methods will have
  760. to certain field variables or methods of a class.  For example, a field variable declared as
  761. "private" can be accessed only by members of the class in which the variable is declared.
  762.  
  763. In addition to "private", there are several other access levels.  Their effects are summarized
  764. in Figure XXX in the "Talk Java to Me" book.
  765. *Protected
  766. Java provides the ability to control what access certain types of methods will have
  767. to certain field variables or methods of a class.  For example, a field variable declared as
  768. "protected" can be accessed only by members of the class in which the variable is declared, or
  769. by sub-classes of that class, or by other methods in the same package.
  770.  
  771. In addition to "protected", there are several other access levels.  Their effects are summarized
  772. in Figure XXX in the "Talk Java to Me" book.
  773. *Public
  774. Java provides the ability to control what access certain types of methods will have
  775. to certain field variables or methods of a class.  For example, a field variable declared as
  776. "public" can be accessed by any method.
  777.  
  778. In addition to "public", there are several other access levels.  Their effects are summarized
  779. in Figure XXX in the "Talk Java to Me" book.
  780. *Reference
  781. Objects in Java are accessed by "reference".  This means that when you declare a variable for
  782. an object, that variable can "reference" any object, and can be assigned to reference different
  783. ones at different times.
  784.  
  785. For example, this code declares two variables of the Date class:
  786.  
  787.     Date a,b;
  788.  
  789. And this code creates a "Date" object, and assigns the variable "a" to reference that object:
  790.  
  791.     a = new Date();
  792.  
  793. If you wish, you can cause "b" to reference the same object with:
  794.  
  795.     a = b;
  796.  
  797. Now a change to EITHER of the variables effects the same object.  For example, you might set the
  798. month with:
  799.  
  800.     a.setMonth(10);
  801.  
  802. That changes the month for both variables, since they reference the same object.
  803.  
  804. This code would then create a second object, and cause "a" to reference it:
  805.  
  806.     a = new Date();
  807.  
  808. But, "b" will still reference the first object.
  809. *Return
  810. This statement causes the execution of a method to end, and the calling method to resume.
  811.  
  812. If the method has a return type other than "void", the "return" statement also indicates
  813. what value is to be returned by the method.  For example:
  814.  
  815.     return;
  816.  
  817. would be used in a method without a return type.  But:
  818.  
  819.     return 5;
  820.  
  821. might be used in a method with a return type of "int".
  822. *Short
  823. This is one of the basic Java data types.  It is used to hold integers (i.e., "whole numbers")
  824. which range from -32,768 to 32,767.  Each "short" takes 16 bits of storage.
  825. *Stack
  826. This is a standard programming data structure.  Objects can be placed on a "stack" in much the
  827. same way that dishes are placed on a stack of dishes.  The can be "pushed" onto the stack (i.e.,
  828. placed on the top of the stack) or "popped" off the stack (i.e., removed from the top).
  829.  
  830. One of the standard set of Java classes is the "Stack" class.  For more information on it,
  831. see Lesson 11.
  832. *Static
  833. A field variable normally exists once for each object.  For example, if you have
  834. a class like this:
  835.  
  836.     public class Date {
  837.  
  838.         int Year;
  839.         int Month;
  840.         int Day;
  841.         static int MonthMax;
  842.  
  843.     }
  844.  
  845. there will be a "year" integer for every "Date" object you create.
  846.  
  847. The "static" keyword can be used to change this, as in the "MonthMax" variable.  There will be
  848. exactly one of those integers, no matter how many "Date" objects there are.  This makes it a
  849. good place to store general information that applies to the entire class, rather than to
  850. individual objects of the class.
  851.  
  852. "static" can be used for methods as well, and has a similar effect.  It means the method
  853. applies to the entire class, not to an individual object.
  854. *Stream
  855. A "stream" is a way of treating a disk file.  It looks at the file as a "stream" of bytes, and
  856. allows you to read through that stream in order from the first byte through to the last.
  857. *String
  858. This is one of the standard Java classes, and it allows you to work with character strings.
  859.  
  860. For example:
  861.  
  862.     String a = "abc";
  863.  
  864. This will create a String object, give it a value of "abc", and assign variable "a" to reference
  865. it.
  866.  
  867. The String class includes a variety of methods that allow you to manipulate the string.  For
  868. futher information, see Lesson 11.  For information about how the "==" and "!=" operators
  869. work with Strings, see lesson 9.
  870. *Synchronized
  871. If your class has multiple threads, each thread can be executing independently of the others.  This
  872. is fine, for the most part, but can be a problem if you want to be sure that only one of the
  873. threads is performing some critical task at once.  For example, you might have a bunch of threads
  874. which are processing requests from a queue.  Naturally, you only want one of the threads removing
  875. a request from the queue at once.  (Otherwise, two threads might end up processing the same
  876. request.)
  877.  
  878. This sort of protection can be added to a program by making a critical piece of code (like
  879. removing a request from a queue) "synchronized".  By making a piece of code synchronized,
  880. Java will insure that only one thread at a time executes it.
  881.  
  882. There are two ways to make code synchronized.  One is by adding the "synchronized"
  883. keyword to a method header, and the other is by using the "synchronized" statement.  Both
  884. methods are described in more detail in Lesson 10.
  885. *Switch
  886. The "switch" statement allows a Java program to select one piece of code from
  887. among several pieces of code based on the value of a variable.  For example:
  888.  
  889.     switch (a) {
  890.  
  891.     case 1:
  892.         b = 5;
  893.         break;
  894.  
  895.     case 4:
  896.         b = 6;
  897.         c = 9;
  898.         break;
  899.  
  900.     default:
  901.         b = 7;
  902.         break;
  903.  
  904.     }
  905.  
  906. This statement will execute one of the three pieces of code listed, based
  907. on the value of "a".  If "a" is 1, the first piece of code will be executed.  If
  908. "a" is 4, the second piece will be executed.  If "a" has any other value, the
  909. third piece will be executed.
  910. *Talk Java to Me
  911. This is the title of an instructional CD-ROM which teaches Java
  912. programming.  Its name comes from the fact that the CD-ROM teaches
  913. by having narrators TALK to you, to explain the language.  This is
  914. the simplest, most natural way to learn, and is a departure from
  915. many instructional CD-ROMS which require the user to read large
  916. quantities of text from the screen.
  917. *Telecommunications
  918. A bit far-fetched.
  919. *Thread
  920. A program often has just one "thread", but can have several.  A "thread" is sort
  921. of like a separate copy of the program that's running, but all the copies
  922. use the same variables.  Each "thread" runs independently
  923. of the other threads, and runs at the same time.  This can allow
  924. different parts of the program to be running simultaneously, or can allow the same part
  925. of the program to be running more than once simultaneously.
  926.  
  927. For more information on "threads", see Lessons 5 and 11.
  928. *Variable
  929. This is a location where data can be stored.
  930.  
  931. There are two types of variables.  The first, "field variables", are variables
  932. that are part of an object.  For example, "month" in the following class
  933. definition is a "field variable":
  934.  
  935.     public class Date {
  936.  
  937.         int year;
  938.         int month;
  939.         int day;
  940.  
  941.     }
  942.  
  943. The other type of variable is a "local variable".  This is a variable created
  944. temporarily during the execution of a method.  For example, "sum" is a
  945. local variable in the following method:
  946.  
  947.     int calcSum(int a) {
  948.  
  949.         int sum = 0;
  950.         int i;
  951.  
  952.         for (i=0; i<a; ++i) {
  953.             sum += i;
  954.         }
  955.  
  956.         return sum;
  957.  
  958.     }
  959. *Vector
  960. A "vector" is another way of saying "array".  It is simply a series of
  961. values, that are treated as a group.  For example, you might have a
  962. vector that is 10 integers, each of which represents the age of an employee.  You could
  963. declare the vector like this:
  964.  
  965.     int ages[10] = {18,18,35,53,39,39,27,44,42,60};
  966.  
  967. You could calculate the average age like this:
  968.  
  969.     float average;
  970.     int sum = 0;
  971.     int i;
  972.  
  973.     for (i=0; i<10; ++i) {
  974.         sum += ages[i];
  975.     }
  976.  
  977.     average = sum / 10;
  978.  
  979. In addition to being a synonym for "array", "vector" can also refer to
  980. an object of the "Vector" class.  The "vector" class is one of the standard
  981. Java classes, and provides a way to create arrays that can have varying sizes.
  982. *While
  983. This is one of the looping statements in Java.  For example:
  984.  
  985.     while (i < 10) {
  986.         sum *= 1.01;
  987.         ++i;
  988.     }
  989.  
  990. This will cause the statements "sum *= 1.01;" and "++i;" to be executed over and
  991. over, as long as "i" remains less than "10".
  992.  
  993. A similar loop is:
  994.  
  995.     do {
  996.         sum *= 1.01;
  997.         ++i;
  998.     } while (i < 10);
  999.  
  1000. The second loop is almost idential to the first.  The only difference is that the
  1001. second loop will always execute the statements "sum *= 1.01;" and "++i" at least once,
  1002. regardless of the initial value of "i".  The first loop, on the other hand, would
  1003. never execute the statements if "i" is at least 10 when the loop begins.
  1004. *End
  1005.